<?php
declare (strict_types = 1);

namespace app\admin\controller;

use think\facade\Cache;
use think\Request;

class Api
{
    //获取奥森图标
    public function getAwesome()
    {
        if (!request()->isAjax()) {
            return msgerror('不是一个正确的请求方式');
        }
        $return = Cache::get('awesome');
        if (empty($return)) {
            $url  = "http://code.zoomla.cn/boot/font.html";
            $content = curl_send(['url' => $url]);
            preg_match_all('/<i\s+class="fa\s+([^"]+)"\s+aria-hidden="true">/is', $content['content'], $icons);
            $return = $icons[1] ? $icons[1] : [];
            Cache::set('awesome', $return, 2592000);
        }
        return datasuccess($return);
    }
}
